<template>
  <div>
    <martin-input class="c-martin__user" v-model="username" placeholder="请输入用户名"/>
    <martin-input type="password" class="c-martin__pass" v-model="password" placeholder="请输入密码"/>
    <martin-button class="c-martin__submit" @click="login">登录</martin-button>
    <martin-button class="c-martin__submit" type="primary" @click="register">注册</martin-button>
  </div>
</template>

<script>
import Input from '@/package/Input/src/Input'
import Button from '@/package/Button/src/Button'

export default {
  name: 'MartinLogin',
  components: {
    'martin-input': Input,
    'martin-button': Button
  },
  data() {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    register() {
      this.$http.get('/register', {
        params: {
          username: this.username,
          password: this.password
        }
      }).then(({data, status}) => {
        if (status === 200) {
        }
      }).catch(err => {
        console.log(err)
      })
    },
    login() {
      this.$http.get('/login', {
        params: {
          username: this.username,
          password: this.password
        }
      }).then(({data, status}) => {
        if (status === 200) {
        }
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style scoped>
.c-martin__user, .c-martin__pass {
  width: 30%;
  float: left;
  margin-right: 20px;
}
.c-martin__submit {
  /* float: left; */
  /* margin-left: 20px; */
}
</style>
